package flc.ast.adapter;

import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

import flc.ast.R;
import me.zhouzhuo.zzratingbar.ZzRatingBar;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.adaptermutil.StkSingleSpanProvider;
import stark.common.bean.StkResBean;

public class ShareAdapter extends StkProviderMultiAdapter<StkResBean> {

    public ShareAdapter() {
        addItemProvider(new StkSingleSpanProvider(126));
        addItemProvider(new ShareProvider());
    }

    private class ShareProvider extends BaseItemProvider<StkResBean> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_share;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, StkResBean bean) {
            Glide.with(getContext()).load(bean.getThumbUrl())
                    .into((ImageView) baseViewHolder.getView(R.id.ivShareItemImg));
            baseViewHolder.setText(R.id.tvShareItemTitle, bean.getName());
            baseViewHolder.setText(R.id.tvShareItemDesc, bean.getDesc());
            List<Integer> list = new ArrayList<>();
            list.add(R.drawable.img1);
            list.add(R.drawable.img2);
            list.add(R.drawable.img3);
            list.add(R.drawable.img4);
            list.add(R.drawable.img5);
            list.add(R.drawable.img6);
            list.add(R.drawable.img7);
            list.add(R.drawable.img8);
            list.add(R.drawable.img9);
            list.add(R.drawable.img10);
            list.add(R.drawable.img11);
            list.add(R.drawable.img12);
            list.add(R.drawable.img13);
            list.add(R.drawable.img14);
            list.add(R.drawable.img15);
            list.add(R.drawable.img16);
            list.add(R.drawable.img17);
            list.add(R.drawable.img18);
            list.add(R.drawable.img19);
            list.add(R.drawable.img20);
            list.add(R.drawable.img21);
            list.add(R.drawable.img22);
            list.add(R.drawable.img23);
            list.add(R.drawable.img24);
            list.add(R.drawable.img25);
            list.add(R.drawable.img26);
            list.add(R.drawable.img27);
            list.add(R.drawable.img28);
            list.add(R.drawable.img29);
            list.add(R.drawable.img30);
            list.add(R.drawable.img31);
            list.add(R.drawable.img32);
            list.add(R.drawable.img33);
            list.add(R.drawable.img34);
            list.add(R.drawable.img35);
            list.add(R.drawable.img36);
            list.add(R.drawable.img37);
            list.add(R.drawable.img39);
            list.add(R.drawable.img40);
            String[] nickName = getContext().getResources().getStringArray(R.array.nick_name);
            Random random = new Random();
            baseViewHolder.setImageResource(R.id.ivShareItemIAvatar, list.get(random.nextInt(list.size())));
            baseViewHolder.setText(R.id.tvShareItemName, nickName[random.nextInt(nickName.length)]);
        }
    }

}
